import config from '@/utils/config'
import { generateRequest } from '@/utils/request'
const { apiUrlPrefix } = config

// 新增角色
export const createRoleApi = generateRequest(`${apiUrlPrefix}/organization/role/insert`)

// 删除角色
export const deleteRoleApi = generateRequest(`${apiUrlPrefix}/organization/role/delete`)

// 修改角色
export const updateRoleApi = generateRequest(`${apiUrlPrefix}/organization/role/update`)

// 查询角色树结构
export const queryRoleTreeApi = generateRequest(`${apiUrlPrefix}/organization/role/getTree`)

// -----------------------------------------------------------------------------------------

// 查询机构树菜单结构
export const queryMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/menus/getMenuTree`)
/**
 * 查询机构钉钉菜单树结构
 */
export const queryDDMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/menus/ding/getDingMenuTree`)

// -----------------------------------------------------------------------------------------

// 查询当前角色下的用户
export const queryUserApi = generateRequest(`${apiUrlPrefix}/organization/role/getUserByRoleId`)

// 将角色下的人员移除
export const removeUserApi = generateRequest(`${apiUrlPrefix}/organization/role/removeUserRole`)

/**
 * 查询角色数据权限配置
 * @type {(function({}=): Promise<void>)|*}
 */
export const queryRolePermissionConfigurationsApi = generateRequest(
  `${apiUrlPrefix}/organization/rolePermissions/queryRolePermissionConfigurations`,
)
/**
 * 保存角色数据权限配置
 * @type {(function({}=): Promise<void>)|*}
 */
export const saveRolePermissionConfigurationsApi = generateRequest(
  `${apiUrlPrefix}/organization/rolePermissions/saveRolePermissionConfigurations`,
)

/** 获取菜单 */
export const getMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/menus/getMenuTree`)
/** 查询当前角色的菜单 */
export const getMenuByRoleIdApi = generateRequest(`${apiUrlPrefix}/organization/role/getMenuByRoleId`)
/** 保存当前角色的菜单 */
export const saveMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/role/saveRoleMenu`)

/** 获取APP权限 */
export const getAppMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/menus/app/getAppMenuTree`)
/** 查询当前角色的APP权限 */
export const getAppMenuTreeByRoleIdApi = generateRequest(`${apiUrlPrefix}/organization/role/getAppMenuByRoleId`)
/** 保存当前角色的APP权限 */
export const saveAppMenuTreeApi = generateRequest(`${apiUrlPrefix}/organization/role/saveRoleAppMenu`)

/** 获取数据权限 */
export const getWardPermissionTreeApi = generateRequest(`${apiUrlPrefix}/organization/menus/getWardPermissionTree`)
/** 查询当前角色的数据权限 */
export const getWardPermissionTreeByRoleIdApi = generateRequest(
  `${apiUrlPrefix}/organization/role/getWardPermissionMenuByRoleId`,
)
/** 保存当前角色的数据权限 */
export const saveWardPermissionTreeApi = generateRequest(`${apiUrlPrefix}/organization/role/saveRoleWardPermissionMenu`)
